package hedron.i18n;

import hedron.Application;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import java.util.logging.Level;

public class Internationalization {
	protected Internationalization() {}

	protected final static Properties properties;
	static {
		final String language = Application.getProperty(Application.CORE_LANGUAGE, "bg").trim().toLowerCase();
		properties = new Properties();

		InputStream is;
		try {
			is = Internationalization.class.getResourceAsStream(language + ".properties");
			properties.load(is);
		} catch (Exception e) {
			try {
				is = Internationalization.class.getResourceAsStream("bg.properties");
				properties.load(is);
			} catch (IOException e1) {
				Application.log.log(Level.OFF, "", e1);
				e1.printStackTrace();
			}
		}
	}

	public static final String _(String key) {
		return properties.getProperty(key, key);
	}
}
